<?php

use think\facade\Route;

$miss = function () {
    $arr = [
        'code' => -1,
        'msg' => '请输入正确的路由地址',
        'data' => []
    ];
    return json($arr);
};
// 主页路由
Route::miss($miss);
// 只需要验证token的放在一起
$func = function () {
    //获取任务详情
    Route::get('home/task/:id', 'app\\home\\controller\\Task@read');
    //获取用户信息
    Route::get('home/userDetail', 'app\\home\\controller\\Member@read');
    //任务领取
    Route::post('home/addTask', 'app\\home\\controller\\Member@addTask');
    //任务提交
    Route::put('home/postTask', 'app\\home\\controller\\Member@post');
    //任务过期
    Route::put('home/task/expire', 'app\\home\\controller\\TaskRecord@expire');
    Route::get('home/taskRecord', 'app\\home\\controller\\TaskRecord@query');
    //商品兑换
    Route::post('home/good/:good_id/exchange', 'app\\home\\controller\\Good@exchange');
    //我的兑换记录
    Route::get('home/myExchange', 'app\\home\\controller\\Member@myExchange');
    //绑定手机号
    Route::put('home/bindPhone', 'app\\home\\controller\\Member@bindPhone');
};
Route::group('home', function () {
    Route::get('task', 'app\\home\\controller\\Task@query');
    Route::get('banner', 'app\\home\\controller\\Banner@query');
    Route::get('notification', 'app\\home\\controller\\Notification@query');
    Route::get('good', 'app\\home\\controller\\Good@query');
    Route::get('good/:id', 'app\\home\\controller\\Good@read');
    Route::post('wxDecode', 'app\\home\\controller\\WxDecode@WxDecode');
    Route::post('sendSms', 'app\\home\\controller\\Sms@sendMessage');
})->allowCrossDomain()->completeMatch(true);
Route::group('', $func)->middleware(app\common\middleware\TokenCheck::class)->allowCrossDomain()->completeMatch(true);